package com.white.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.white.bean.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    String TABLE_NAME = " User ";
    String SELECT = "select * from" + TABLE_NAME + "where ";

    int LIMIT = 10;
    @Select("select * from user where name = #{name} and password = #{password}")
    User login(String name, String password);

    @Select("select * from user where name like #{content}")
    List<User> mySearch(String content);

    @Select("select * from user\n" +
            "where userId in (\n" +
            "select beFollowUserId from follow\n" +
            "where followUserId = #{userId}\n" +
            ")")
    List<User> getFollowByUserId(Long userId);

    @Select("select * from user\n" +
            "where userId in (\n" +
            "select followUserId from follow\n" +
            "where beFollowUserId = #{userId}\n" +
            ")")
    List<User> getFanByUserId(Long userId);

    @Select("select * from user\n" +
            "where userId in (\n" +
            "select blockUserId from block\n" +
            "where userId = #{userId}\n" +
            ")")
    List<User> getBlock(Long userId);
}
